/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2012-2020. All rights reserved.
 * Description: event sched sysfs
 * Author: Huawei Technologies Co., Ltd.
 * Create: 2020/1/2
 */

#ifndef _EVENT_SYSFS_H_
#define _EVENT_SYSFS_H_

#include <linux/device.h>
#include "hdcdrv_core.h"

#define HDCDRV_ATTR_RD (S_IRUSR | S_IRGRP)
#define HDCDRV_ATTR_WR (S_IWUSR | S_IWGRP)
#define HDCDRV_ATTR_RW (HDCDRV_ATTR_RD | HDCDRV_ATTR_WR)

struct hdcdrv_cmd_get_stat {
    int ret;
    int dev_id;       /* input, -1 not care */
    int pid;
    int service_type; /* input, -1 not care */
    int session;      /* input, -1 not care */
    int chan_id;      /* input, -1 not care */
    void *outbuf;     /* output */
};

struct hdcdrv_sysfs_ctrl_msg_head {
    int type;
    int error_code;
    u32 msg_len;
    u32 para;
};

struct hdcdrv_sysfs_ctrl_msg {
    struct hdcdrv_sysfs_ctrl_msg_head head;
    char data[PAGE_SIZE];
};

struct hdcdrv_cmd_stat_session_brief {
    int active_num;
    int active_list[HDCDRV_SURPORT_MAX_SESSION];
    int remote_close_num;
    int remote_close_list[HDCDRV_SURPORT_MAX_SESSION];
    int idle_num;
    int idle_list[HDCDRV_SURPORT_MAX_SESSION];
    int accept_num;
    int connect_num;
    int close_num;
};

struct hdcdrv_cmd_stat_all {
    int dev_num;
    int dev_list[HDCDRV_SURPORT_MAX_DEV];
    struct hdcdrv_cmd_stat_session_brief s_brief;
};

struct hdcdrv_mem_info {
    unsigned int small_pool_size;
    unsigned int small_pool_remain_size;
    unsigned int huge_pool_size;
    unsigned int huge_pool_remain_size;
};
struct hdcdrv_cmd_stat_dev_service {
    struct hdcdrv_cmd_stat_session_brief s_brief;
    struct hdcdrv_stats stat;
    struct hdcdrv_mem_info tx_mem_info;
    struct hdcdrv_mem_info rx_mem_info;
};

struct hdcdrv_cmd_stat_chan {
    int w_sq_head;
    int w_sq_tail;
    int r_sq_head;
    int dma_head;
    int rx_head;
    int submit_dma_head;
    struct hdcdrv_stats stat;
    struct hdcdrv_dbg_stats dbg_stat;
};
struct hdcdrv_cmd_stat_session {
    int dev_id;
    int service_type;
    int status;
    int fast_chan_id;
    int chan_id;
    int local_session;
    int remote_session;
    int pkts_in_fast_list;
    int pkts_in_list;
    int remote_close_state;
    int local_close_state;
    struct hdcdrv_stats stat;
    struct hdcdrv_timeout timeout;
};

void hdcdrv_sysfs_init(struct device *dev);
void hdcdrv_sysfs_uninit(struct device *dev);
int hdcdrv_sysfs_ctrl_msg_get_session_stat(u32 dev_id, struct hdcdrv_sysfs_ctrl_msg *msg, u32 *real_out_len);
int hdcdrv_sysfs_ctrl_msg_get_chan_stat(u32 dev_id, struct hdcdrv_sysfs_ctrl_msg *msg, u32 *real_out_len);

#endif

